package com.his.struts.util;

import java.util.List;

public class PageInfoBean<T> {

	private int totalRow;

	private int pageNo;

	private int pageSize;

	private int currentPage;

	private int totalPage;

	private List<T> data;

	public PageInfoBean(int pageNo, int pageSize,int totalRow) {
		super();
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.totalRow = totalRow;
		this.totalPage = totalRow % pageSize == 0 ? totalRow / pageSize
				: (totalRow / pageSize) + 1;
	}

	public int getTotalRow() {
		return totalRow;
	}

	public void setTotalRow(int totalRow) {
		this.totalRow = totalRow;
	}

	public int getPageNo() {
		if (pageNo < 1)
			return 1;

		if (pageNo > this.getTotalPage())
			return getTotalPage();

		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return getPageNo();
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getTotalPage() {
		return totalPage;
	}

}
